﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Specialized;

/// <summary>
/// Summary description for GetProfile
/// </summary>
public class AboutUser
{
    /// <summary>
    /// Constructor
    /// </summary>
    public AboutUser()
    {
        jParser = new JsonParser();
        no_of_friends = 0;
    }

    JsonParser jParser = null;
    int no_of_friends;
    
    /// <summary>
    /// Get User Profile
    /// </summary>
    /// <param name="response">Json Text</param>
    /// <returns></returns>
    public Person getProfile(string response)
	{
        string data = jParser.getData(true, response, "data");
        Person person = jParser.getProfile(data);

        return person;
	}

    /// <summary>
    /// Get User Friends
    /// </summary>
    /// <param name="response">Json Text</param>
    /// <param name="requiredFriends">No. Of Friends</param>
    /// <returns></returns>
    public Person[] getFriends(string response,int requiredFriends)
    {
        string data = jParser.getData(true, response, "data");
        no_of_friends = jParser.getCount(data);

        string friendData = String.Empty;
        friendData = jParser.getData(false, data, "list");

        no_of_friends = (no_of_friends < requiredFriends) ? no_of_friends : requiredFriends;

        Person[] person = jParser.getFriends(friendData, no_of_friends);

        return person;
    }
}
